package com.hans.scala.actor

import actors._, Actor._

/**
 *
 * Created by Hans on 2014/4/9.
 */
object ReceiveActor {
  def main(args: Array[String]) {
    val echoActor = actor {
      while (true) {
        println("==while receive==")
        receive {
          case msg => println("while receive msg:" + msg)
//            throw new Exception("while exception")
        }
      }
    }
    val intActor = actor {
      loop {
        println("==loop receive==")
        receive {
          case msg: Int => println("loop receive msg:" + msg)
//            throw new Exception("loop exception")
        }
      }
    }

    echoActor ! "hans"
    echoActor ! 15
//    intActor ! "hans"
    intActor ! 15
    intActor ! 16
    Thread.sleep(1000)

  }
}
